//
//  MZYleadViewController.m
//  WristWatch
//
//  Created by dllo on 15/11/9.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "MZYleadViewController.h"
#import "AppDelegate.h"

@interface MZYleadViewController ()<UIScrollViewDelegate>
@property(nonatomic, retain)UIScrollView *scrollView;
@property(nonatomic, retain)NSArray *arr;

@end

@implementation MZYleadViewController

- (void)dealloc {
    [_scrollView release];
    [_arr release];
    
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
    [self.view addSubview:self.scrollView];
    self.scrollView.showsHorizontalScrollIndicator = NO;
//    self.scrollView.bounces = NO;
    self.scrollView.delegate = self;
    
    self.arr = @[@"m", @"z", @"y", @"s"];
    
    UIImageView *imageView1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
    [self.scrollView addSubview:imageView1];
    [imageView1 release];
    
    UIImageView *imageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH, 0, WIDTH, HEIGHT)];
    [self.scrollView addSubview:imageView2];
    [imageView2 release];
    
    UIImageView *imageView3 = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH * 2, 0, WIDTH, HEIGHT)];
    [self.scrollView addSubview:imageView3];
    [imageView3 release];
    
    UIImageView *imageView4 = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH * 3, 0, WIDTH, HEIGHT)];
    [self.scrollView addSubview:imageView4];
    [imageView4 release];
    
    
    imageView1.image = [UIImage imageNamed:@"m"];
    imageView2.image = [UIImage imageNamed:@"z"];
    imageView3.image = [UIImage imageNamed:@"y"];
    imageView4.image = [UIImage imageNamed:@"s"];
    
    
    // 移动的范围
    self.scrollView.contentSize = CGSizeMake(self.arr.count * self.view.frame.size.width, 0);
    //    [self.scrollView setContentOffset:CGRectMake(0, 0, self.InfoArr.count * WIDTH, 0) animated:YES];
    // 按页滚动
    self.scrollView.pagingEnabled = YES;
    [_scrollView release];

}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    CGFloat offsetX = self.scrollView.contentOffset.x;
    if (offsetX > self.view.frame.size.width * 3) {
        
        AppDelegate *appVC = (AppDelegate *)[[UIApplication sharedApplication]delegate];
        [[UIApplication sharedApplication].keyWindow setRootViewController:appVC.tab];
    }
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
